package com.example.campus;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class SearchActivity extends Activity implements OnPageChangeListener,
		OnClickListener {
	TextView info1;
	TextView info2;
	TextView info3;
	TextView info4;
	Indicator indicator;
	ViewPager vp;

	public void onCreate(Bundle b) {
		super.onCreate(b);
		setContentView(R.layout.view_main);
		indicator = (Indicator) findViewById(R.id.indicator);
		info1 = (TextView) findViewById(R.id.tab_one);
		info1.setText("查课表");
		info1.setOnClickListener(this);
		info2 = (TextView) findViewById(R.id.tab_two);
		info2.setText("查成绩");
		info2.setOnClickListener(this);
		info3 = (TextView) findViewById(R.id.tab_three);
		info3.setOnClickListener(this);
		info3.setText("查会议");
		info4 = (TextView) findViewById(R.id.tab_four);
		info4.setOnClickListener(this);
		info4.setText("查校历");
		vp = (ViewPager) findViewById(R.id.viewpager);
		String[] tab = new String[] {
				"http://www.xaufe.edu.cn/Information/MeetingPlan.html",
				"http://www.xaufe.edu.cn/Information/MeetingPlan.html",
				"http://www.xaufe.edu.cn/Information/MeetingPlan.html",
				"http://www.xaufe.edu.cn/UpImages/2015829152649460.jpg" };
		vp.setAdapter(new WebAdapter(tab, this));
		vp.setOnPageChangeListener(this);
		vp.setOffscreenPageLimit(4);

	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if (v.getId() == R.id.tab_one)
			vp.setCurrentItem(0);
		else if (v.getId() == R.id.tab_two)
			vp.setCurrentItem(1);
		else if (v.getId() == R.id.tab_three)
			vp.setCurrentItem(2);

		else if (v.getId() == R.id.tab_four)
			vp.setCurrentItem(3);
	}

	@Override
	public void onPageScrollStateChanged(int arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onPageScrolled(int arg0, float arg1, int arg2) {
		// TODO Auto-generated method stub
		indicator.scroll(arg0, arg1);
	}

	@Override
	public void onPageSelected(int arg0) {
		// TODO Auto-generated method stub

	}
}
